home *** CD-ROM | disk | FTP | other *** search
- #include <string.h>
- #include <dos.h>
- #include "function.h"
-
- static char buffer[128];
-
- /* ファイルの作成時刻を取得する */
- unsigned long FileTime( char *FileName )
- {
- int fh;
- unsigned int date,time;
-
- if( _dos_open( FileName,0x00,&fh ) ) return( 0 );
- if( _dos_getftime( fh,&date,&time ) ) return( 0 );
- _dos_close( fh );
- return( (date << 16) + time );
- }
-
- /* カレントまたはリストのディレクトリからファイルを探す */
- char *FindFile( char *FileName,char *PathList )
- {
- int fh;
- char *path,*p;
-
- if( _dos_open( FileName,0x00,&fh ) == 0 ) {
- _dos_close( fh );
- return( FileName );
- }
-
- path = PathList;
- while( *path == ' ' ) path++;
- while( path && *path && *path != ';' ) {
- p = buffer;
- while( *path && *path != ';' ) *p++ = *path++;
- if( *path == ';' ) path++;
- if( *(p-1) != '\\' ) *p++ = '\\';
- strcpy( p,FileName );
- if( _dos_open( buffer,0x00,&fh ) == 0 ) {
- _dos_close( fh );
- return( buffer );
- }
- }
- return( NULL );
- }
-
- /* パス名とファイル名を結合する */
- char *JoinPath( char *path,char *FileName )
- {
- char *p;
-
- p = buffer;
- if( *path ) {
- while( *path ) *p++ = *path++;
- if( *(p-1) != '\\' ) *p++ = '\\';
- }
- strcpy( p,FileName );
- return( buffer );
- }
-
- /* パスからファイルの拡張子を探す */
- char *SearchExt( char *path )
- {
- char *p;
-
- if( p = strrchr( path,'\\' ) ) path = p;
- else p = path;
- if( p = strrchr( path,'.' ) ) path = p;
- else while( *path ) path++;
- return( path );
- }
-
- /* パスからファイル名を探す */
- char *SearchFile( char *path )
- {
- char *p;
-
- if( p = strchr( path,':' ) ) path = p++;
- else p = path;
- if( p = strrchr( path,'\\' ) ) path = p++;
- else p = path;
- return( path );
- }
-
-